*** Diminish Expectations: Redistributive Preferences in Truncated Welfare States
*** Alisha C. Holland
*** August 2018

*** Using LAPOP 2008, 2010, 2012, 2014, and 2016 waves
*** Available at http://datasets.americasbarometer.org/database/
*** LAPOPCombined.dta includes the variables used in the paper merged with the higher-level variables

*** Survey weights for comparative analysis so all countries are equally weighted 
svyset upm [pw=wt], strata (estratopri) 

*** Preparing the LAPOP data
*** Country codes 
generate country = "Mexico" if pais==1
replace country = "Mexico" if pais==1
replace country = "Guatemala" if pais==2
replace country= "El Salvador" if pais==3
replace country= "Honduras" if pais==4
replace country="Nicaragua" if pais==5
replace country="Costa Rica" if pais==6
replace country="Panama" if pais==7
replace country="Colombia" if pais==8
replace country="Ecuador" if pais==9
replace country="Bolivia" if pais==10
replace country="Peru" if pais==11
replace country="Paraguay" if pais==12
replace country="Chile" if pais==13
replace country="Uruguay" if pais==14
replace country="Brazil" if pais==15
replace country="Venezuela" if pais==16
replace country="Argentina" if pais==17
replace country="Dom. Rep." if pais==21

***** Main Dependent Variables 

** Support for redistribution on its full scale, 1 = disagree, 7 = agree
rename ros4 redistribution 
label variable redistribution "Redistribution"

** Redistribution recoded as a binary variable for those strongly supportive (6 or 7)
generate demand = ros4
replace demand = 1 if ros4 > 5
replace demand = 0 if ros4 <6 & ros4 >0
replace demand =. if ros4>8
label variable demand "Demand" 

**** Independent Variables 

*** Benefit Inclusion

*** CCT: "1" if receives (for countries with single question)
generate cct = .
replace cct = cct1b
recode cct (2=0)
*** Bolivia: "1" if receives any cct program (Renta dignidad, Bono Juancito Pinto, Bono Juana Azurduy)
generate cct = .
replace cct = 1 if bolcct1a==1|bolcct1b==1|bolcct1c==1
replace cct =0 if bolcct1a==2 & bolcct1b==2 & bolcct1c==2
*** El Salvador: "1" if receives either cct program 
generate cct = .
replace cct = 1 if cct1b==1|cct1c==1
replace cct =0 if cct1b==2 & cct1c==2

*** Subsidy: "1" if receives, only asked 2014 and 2016
generate subsidy = .
replace subsidy = wf1
recode subsidy (2=0)

*** Pension: "1" if contributes
generate pension = . 
replace pension = pen1
recode pension (2=0)
replace pension =. if pen1>3

*** Health: "1" if covered
generate health=.
replace health=sal1
recode health(2=0)
replace health=. if sal1 >3 

*** Benefits: "1" if the person gets anything
generate benefits = 0
replace benefits = 1 if subsidy==1|pension==1|health==1|cct==1
replace benefits = . if subsidy==.&pension==.&health==.&cct==.

*** Income: wealth proxy for income using country-specific pca for wealth deciles, 
*** run for each country-year file
pca r1 r3 r4 r4a r5 r6 r7 r8 r12 r14 r15 r18 r16 r26
predict pca2, score
generate consumption = pca2
xtile consumpd = consumption, nq(10)
generate deciles = (consumpd-1)/9

*** Education: rescaled years up to 18 to run from 0 to 1
generate education = ed/18
replace education =1 if ed>18

*** Female: "1" if female 
generate female = 0 if q1==1  
replace female = 1 if q1==2

** Size: Categories of place where person lives, recoded from most rural to city
generate size = tamano
recode size (1=5)(2=4)(3=3)(4=2)(5=1)
replace size = (size-1)/4

**Age: ages 16 to 99, rescaled from 0 to 1
generate age = q2
replace age=. if q2<16
replace age=. if q2>99
replace age = (age-16)/83
generate agesquared= age^2

*** Nonwhite: "1" if indigenous, black, mulatto (0 is white and mestizo)
generate nonwhite = 0 if etid==2
replace nonwhite = 0 if etid==1
replace nonwhite = 1 if etid >2 & etid<6
replace nonwhite = 0 if etid==7|etid==6
replace nonwhite = . if etid>7

*** State Reach: time for medical attention to come if you call, slow to fast
*** Only asked in 2016
generate healthresponse = infra3
recode healthresponse (1=5)(2=4)(3=3)(4=2)(5=1)(6=0)
replace healthresponse =. if infra3>6
replace healthresponse = healthresponse/5

*** Additional Covariates

*** Unemployed: "1" if unemployed 
generate unemployed = 1 if ocup4a==3
replace unemployed = 0 if ocup4a<3|ocup4a>3

*** Shock: "1" if income went down in previous year
generate shock = 1 if q10e==3
replace shock = 0 if q10e==1|q10e==2

*** Religion: based on attendance, rescaled from 0 to 1, "0" if never attends church, "1" if attends church once a week 
generate religion= cp6
recode religion (4=1)(3=2)(2=3)(1=4)
replace religion = (religion-1)/3

*** Right: rescaled from 0 (far left) to 1 (far right)
generate right = (l1-1)/9

*** Client: "1" if frequently or sometimes offered gift/favor in 2010 and 2012; 
*** "1" if ever approached in 2014
generate client = .
replace client =0 if clien1==3& year==2010|clien1==3 & year==2010
replace client =0 if clien1==3& year==2012|clien1==3 & year==2012
replace client =1 if clien1==0& year==2010|clien1==1 & year==2010
replace client =1 if clien1==0& year==2012|clien1==1 & year==2012
replace client = 1 if clien1na==1 & year==2014
replace client = 0 if clien1na==2 & year==2014

*** Crime: "1" if names crime, gangs, narcos, violence or lack of security as largest problem in country
generate crimeproblem = .
replace crimeproblem = 1 if a4==5|a4==57|a4==27|a4==14|a4==12
replace crimeproblem = 0 if a4!=5 & a4!=57 & a4!=27 & a4!=14 & a4!=12 & a4!=.

*** Corruption: "1" if paid bribe to bureaucrat
gen bbribe = exc6
recode bbribe (2=0)
replace bbribe =. if exc6>3


*** Figure 1: Inequality and Income Coefficients 

*** Income Coefficients 
*** Allow the slopes and country intercepts to vary to get BLUPs and their standard errors,
*** Using year fixed effects 
mixed redistribution deciles education female age i.year || country: deciles
predict countryslope countryint, reffects reses (se_country se_int)
*** Account for the intercept of the sample 
gen totalslope = countryslope + _b[deciles]
*** Get standard error for coefficients
*** Random effects model assumes that covariance of se_country, _se[deciles]= 0
gen vartotal = se_country^2 + (_se[deciles])^2
gen se_slope = sqrt(vartotal)

preserve
collapse demand totalslope gini_market5, by(country)
*** Left panel: income coefficients and market inequality, drop Venezuela from linear estimate
*** Clean up place labels
generate where = 6
replace where = 1 if country=="Costa Rica"|country=="Uruguay"|country=="Venezuela"
replace where=8 if country=="Nicaragua"
graph twoway (lfit totalslope gini_market5 if country!="Venezuela", lcolor(gray))(scatter totalslope gini_market5, ylab(-.1(.02).04, nogrid) mlabel(country) mcolor(black) msymbol(smcircle) mlabvposition(where) mlabcol(black) ytitle(Income Coefficient) xtitle(Gini Coefficient (Market Income)) plotregion(fcolor(white)) graphregion(color(white) lcolor(white)) legend(off))
graph export figure1left.tif, width(2550)
*** Right panel: fraction supportive of redistribution and market inequality, drop Venezuela
replace where = 6
replace where = 1 if country=="Venezuela"|country=="Dom. Rep."
replace where = 11 if country=="Costa Rica"
graph twoway (lfit demand gini_market5 if country!="Venezuela", lcolor(gray))(scatter demand gini_market5, ylab(.4(.1).8, nogrid) mlabel(country) mcolor(black) msymbol(smcircle) mlabvposition(where) mlabcol(black) ytitle(Share that Supports Redistribution) xtitle(Gini Coefficient (Market Income)) plotregion(fcolor(white)) graphregion(color(white) lcolor(white)) legend(off))
graph export figure1right.tif, width(2550)
restore

*** Estimate income coefficient for each country-year
generate slopesc=0
generate slopesc_se=0
generate totalslopesc =0
generate totalvar=0

levelsof year, local(myyears)
foreach i of local myyears {
mixed redistribution deciles education female age || country: deciles if year == `i'
predict u1 u2 if year ==`i' , reffects reses (se1 se2) 
replace slopesc=u1 if year == `i'
replace totalslopesc = slopesc + _b[deciles] if year == `i'
replace slopesc_se = se1 if year == `i'
replace totalvar = slopesc_se^2 + (_se[deciles])^2 if year == `i'
replace se_slopesc = sqrt(totalvar)
drop u1 u2 se1 se2
}


*** Count if coefficients are greater than 0 for 90 country-years
preserve
collapse totalslopesc, by(country year)
count if totalslopesc>0
restore


*** Figure 2. Redistributive Impact  

*** Download SWIID V5.1, Use SWIID V5.1.dta
*** Pull the core estimates of net, market, relative and absolute redistribution
keep country year _*
foreach v in gini_net gini_market rel_red abs_red {
    egen `v' = rowmean(_*`v')
    egen `v'_se = rowsd(_*`v')
    gen `v'_95ub = `v' + 1.96*`v'_se
    gen `v'_95lb = `v' - 1.96*`v'_se
}
drop _*
sort country year

*** Plot shows pooled averages from 2006-15
preserve
keep country year gini_net gini_market rel_red abs_red
keep if year ==2008|year==2010|year==2012|year==2014|year==2015
bysort country: egen abs_red_mean = mean(abs_red) 
bysort country: egen gini_market_mean = mean(gini_market) 
drop if abs_red_mean== .
generate LatAm = 0
replace LatAm=1 if country=="Argentina"|country=="Bolivia"|country=="Brazil"|country=="Chile"|country=="Colombia"|country=="Costa Rica"|country=="Dominican Republic"
replace LatAm=1 if country=="Ecuador"|country=="El Salvador"|country=="Guatemala"|country=="Honduras"|country=="Mexico"|country=="Nicaragua"|country=="Panama"|country=="Paraguay"|country=="Peru"|country=="Uruguay"|country=="Venezuela"

**OECD members
generate Europe =0
replace Europe=1 if country=="Austria"|country=="Australia"|country=="Belgium"|country=="Canada"|country=="Czech Republic"|country=="Denmark"|country=="Estonia"
replace Europe=1 if country=="Finland"|country=="France"|country=="Germany"|country=="Greece"|country=="Hungary"|country=="Iceland"|country=="Ireland"|country=="Italy"
replace Europe=1 if country=="Latvia"|country=="Luxembourg"|country=="Netherlands"|country=="Norway"|country=="Poland"|country=="Portugal"|country=="Romania"
replace Europe=1 if country=="Slovakia"|country=="Slovenia"|country=="Spain"|country=="Sweden"|country=="Japan"|country=="Switzerland"
replace Europe=1 if country=="Korea, Republic of"|country=="Israel"|country=="United States"|country=="Canada"

** Fix the country labels
gen country2 = "Argentina" if country=="Argentina"
replace country2 = "Colombia" if country=="Colombia"
replace country2 = "Brazil" if country=="Brazil"
replace country2 = "Honduras" if country=="Honduras"
replace country2 = "Uruguay" if country=="Uruguay"
replace country2 = "Venezuela" if country=="Venezuela" 

gen country3= "France" if country=="France" 
replace country3= "Sweden" if country=="Sweden" 
replace country3= "Switzerland" if country=="Switzerland" 
replace country3= "Germany" if country=="Germany" 
replace country3= "United States" if country=="United States" 
replace country3= "Canada" if country=="Canada" 
replace country3= "Ireland" if country=="Ireland" 
replace country3= "S. Korea" if country=="Korea, Republic of" 
replace country3="South Africa" if country=="South Africa"

*** Redistribution reduces Gini by 18 points in Europe
summarize abs_red_mean if Europe==1 
*** And 3 points in Lat Am
summarize abs_red_mean if LatAm==1 

*** Adjust country labels
generate where = 6

** Plot shows mean from 2008-15, but only keep one year not to repeat points
keep if year==2010
twoway (scatter abs_red_mean gini_market_mean if LatAm==1, mcolor(black) mlabcolor(black) msymbol(smcircle) msize(large) mlabel(country2) mlabvposition(where))(scatter abs_red_mean gini_market_mean if Europe==1, mcolor(gray) mlabcolor(gray) msymbol(smcircle) msize(large) mlabel(country3) mlabvposition(where)) (scatter abs_red_mean gini_market_mean if LatAm==0 & Europe==0 , mcolor(gray) mlabcolor(gray) msymbol(smtriangle) msize(small) mlabel(country3) mlabvposition(where))(lfit abs_red_mean gini_market_mean if Europe==1, lcolor(gray))(lfit abs_red_mean gini_market_mean if Europe==0 & LatAm==0, lcolor(gray) lpattern(dash))(lfit abs_red_mean gini_market_mean if LatAm==1, lcolor(black) ytitle("Absolute Redistribution") xtitle("Market Inequality") xlab(30(10)70) ylab(0(5)30, nogrid) graphregion(fcolor(white)) plotregion(fcolor(white)) bgcolor(white) legend( order(1 "Latin America" 2 "OECD" 3 "Other") rows(1) pos(5)))
graph export figure2b.tif, width(2550)

*** Redistribution barely improves inequality in Colombia and Guatemala
summarize abs_red_mean if country=="Colombia"
summarize abs_red_mean if country=="Guatemala"
summarize abs_red_mean if country=="Uruguay"
restore

*** Figure 4. The Relationship between Benefit Receipt and Redistributive Preferences
*** Using CombinedLAPOP.dta
** Standardize the variables for ease of comparison
egen stdbenefits = std(benefits)
egen stddeciles = std(deciles)
egen stded= std(education)
egen stdsize = std(size)
egen stdhealth = std(healthresponse) 
egen stdage= std(age)
egen stdright=std(right)
egen stdreligion=std(religion)
egen stdclient=std(client)
egen stdcrimeproblem=std(crimeproblem)

label variable stdbenefits "Benefits"
label variable stddeciles "Income"
label variable stded "Education"
label variable stdage "Age"
label variable nonwhite "Nonwhite"
label variable stdsize "Size" 
label variable stdhealth "State Reach"
label variable pension "Pension"
label variable health "Health"
label variable subsidy "Subsidy"
label variable cct "CCT"
label variable age "Age"
label variable religion "Religion"

*** Plot the coefficients 
xi: reg redistribution benefits stddeciles stded female stdsize stdage nonwhite i.country i.year, robust
estimates store A
xi: reg redistribution benefits bbribe stddeciles stded female stdsize stdage nonwhite stdright stdreligion unemployed stdclient stdcrimeproblem i.country i.year, robust
estimates store B
xi: reg redistribution benefits stdhealth stddeciles stded female stdsize stdage nonwhite i.country i.year, robust
estimates store C
coefplot (A, label("Model 1, Baseline, N=106,241") mcolor(black) msymbol(circle)) (B, label("Model 2, Controls, N=50,672") mcolor(gray)msymbol(triangle)) (C, label("Model 3, State Reach, N=23,649") mcolor(gray) msymbol(dh)) ,keep(*benefits *stddeciles *stded *female *stdsize *stdage *nonwhite *stdhealth) xline(0) xtitle("Coefficient Estimates and 95% Confidence Intervals") scheme(s1mono) graphregion(fcolor(white)) plotregion(fcolor(white)) bgcolor(white) grid(none) legend(rows(2))
graph export figure4.tif, width(2550)

*** Substantive impacts for predicting strong redistributive support for average nonwhite female in Guatemala 
preserve
estsimp logit demand benefits deciles education female size age nonwhite healthresponse if country=="Guatemala" & year==2016
setx mean
setx female 1 nonwhite 1 benefits 0 healthresponse 0
simqi, prval(1)
setx female 1 nonwhite 1 benefits 1 healthresponse 0
simqi, prval(1)
setx healthresponse 1
simqi, prval(1)
restore

preserve
estsimp logit demand benefits deciles education female size age nonwhite healthresponse if country=="Uruguay" & year==2016
setx mean
setx female 1 nonwhite 1 benefits 0 healthresponse 0
simqi, prval(1)
setx female 1 nonwhite 1 benefits 1 healthresponse 0
simqi, prval(1)
restore


*** Figure 5. Welfare State Truncation and Income Coefficients

*** Merge in ASPIRE data 
*** merge m:1 pais year using coveragevariables
*** drop _merge

*** Using the total slope (that includes the intercept)
*** Maximum coverage of social insurance and assistance
preserve
collapse totalslope maxcov_near cov_sa_near cov_si_near abs_red gini_sa gini_si, by(country)
*** Average social insurance and assistance coverage 
gen covaverage = (cov_sa_near + cov_si_near)/200
generate where = 6
replace where=9 if country=="Argentina"
replace where=3 if country=="Dom. Rep."
replace where=12 if country=="Costa Rica"|country=="El Salvador"
graph twoway (lfit totalslope covaverage, lcolor(gray))(scatter totalslope covaverage, ylab(-.12(.02).04, nogrid) mlabel(country) mcolor(black) msymbol(smcircle) mlabvposition(where) mlabcol(black) ytitle(Income Coefficient) xtitle(Coverage) plotregion(fcolor(white)) graphregion(color(white) lcolor(white)) legend(off))
graph export figure5top.tif, width(2550)
*** Absolute redistribution
replace where=12 if country=="Peru"
replace where=1 if country=="Mexico"
replace where=3 if country=="Argentina"
replace where=3 if country=="Costa Rica"
graph twoway (lfit totalslope abs_red, lcolor(gray))(scatter totalslope abs_red, ylab(-.12(.02).04, nogrid) mlabel(country) mcolor(black) msymbol(smcircle) mlabvposition(where) mlabcol(black) ytitle(Income Coefficient) xtitle(Absolute Redistribution) plotregion(fcolor(white)) graphregion(color(white) lcolor(white)) legend(off))
graph export figure5middle.tif, width(2550)
*** Benefit redistribution, total reducing in Gini from social insurance and assistance 
generate ginisasi = gini_sa + gini_si
replace where=12 if country=="Costa Rica"|country=="Mexico"|country=="Argentina"
replace where = 3 if country=="Paraguay"
replace where = 5 if country=="Colombia"
graph twoway (lfit totalslope ginisasi, lcolor(gray))(scatter totalslope ginisasi, ylab(-.12(.02).04, nogrid) mlabel(country) mcolor(black) msymbol(smcircle) mlabvposition(where) mlabcol(black) ytitle(Income Coefficient) xtitle(Benefit Redistribution) plotregion(fcolor(white)) graphregion(color(white) lcolor(white)) legend(off))
graph export figure5bottom.tif, width(2550)
restore

*** Table 1. Predicting Income Coefficients with Coverage and Progressivity

preserve
collapse totalslope covaverage abs_red gini_market5 socialexp gni_pc_1000 effectiveness_raw ef inc lrule se_slope, by(country year)
label variable covaverage "Coverage"
label variable gini_market5 "Inequality"
label variable socialexp "Social Exp"
label variable gni_pc_1000 "GDP"
label variable ef "Ethnicity"
label variable inc "Income Tax"
label variable lrule "Left Rule"
label variable effectiveness_raw "Effectiveness"
label variable abs_red "Ab. Redis."
eststo clear
eststo, title("Model 1"): quietly reg totalslope covaverage gini_market5 socialexp gni_pc_1000 i.year [aweight=1/se_slope]
eststo, title("Model 2"): quietly reg totalslope covaverage gni_pc_1000 gini_market5 socialexp effectiveness_raw i.year [aweight=1/se_slope]
eststo, title("Model 3"): quietly reg totalslope covaverage gni_pc_1000 gini_market5 socialexp ef i.year [aweight=1/se_slope]
eststo, title("Model 4"): quietly reg totalslope covaverage gni_pc_1000 gini_market5 socialexp inc i.year [aweight=1/se_slope]
eststo, title("Model 6"): quietly reg totalslope covaverage gni_pc_1000 gini_market5 socialexp lrule i.year [aweight=1/se_slope]
eststo, title("Model 1"): quietly xi: reg totalslope abs_red gini_market5 socialexp gni_pc_1000 i.year [aweight=1/se_slope]
eststo, title("Model 2"): quietly xi: reg totalslope abs_red gni_pc_1000 gini_market5 socialexp effectiveness_raw i.year [aweight=1/se_slope]
eststo, title("Model 3"): quietly xi: reg totalslope abs_red gni_pc_1000 gini_market5 socialexp ef i.year [aweight=1/se_slope]
eststo, title("Model 4"): quietly xi: reg totalslope abs_red gni_pc_1000 gini_market5 socialexp inc i.year [aweight=1/se_slope]
eststo, title("Model 6"): quietly xi:  reg totalslope abs_red gni_pc_1000 gini_market5 socialexp lrule i.year [aweight=1/se_slope]
estout, style(tex) varlabels(_cons \_cons) 
esttab using papertab1.tex, keep(covaverage abs_red gini_market5 socialexp gni_pc_1000 effectiveness_raw ef inc lrule) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Table 1\label{higherorder}")
restore



*** Figure 6. Support for Social Policy Across Domains by Class
*** Use Colombia2014Survey.dta

*** Create binary variables that take on a value of ``1'' if respondent agrees or strongly agrees

generate taxav = 1 if tax > .4
replace taxav = 0 if tax <.4 

generate targetav = 1 if targetspend > .4
replace targetav = 0 if targetspend <.4 

generate housingav = 1 if housing > .4
replace housingav = 0 if housing <.4 

generate healthav = 1 if health > .4
replace healthav = 0 if health <.4 

generate reav = 1 if redistribution > .4
replace reav = 0 if redistribution <.4

generate empav = 1 if employment > .4
replace empav = 0 if employment <.4 

*** Left panel: Progressive programs
preserve
 lpoly taxav strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(treat1) se(treat_se1)
 lpoly targetav strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(control1) se(control_se2)
 lpoly healthav strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(treat2) se(treat_se2)
g treated_upper1 = treat1 + (treat_se1)*1.96
g treated_lower1 = treat1 - (treat_se1)*1.96
g untreated_upper1 = control1 + (control_se)*1.96
g untreated_lower1 = control1 - (control_se)*1.96
g treated_upper2 = treat2 + (treat_se2)*1.96
g treated_lower2 = treat2 - (treat_se2)*1.96
sort strata
graph twoway line treat1 control1 treat2 treated_upper1 treated_lower1 untreated_upper1 untreated_lower1 treated_upper2 treated_lower2  strata, legend(order(1 "Tax" 2 "CCTs" 3 "Health" ) rows(1)) ytitle("Share that Approves") xtitle("Strata (low to high)") scheme(s1color)  lcolor(black black black gray gray gray gray gray gray) lpattern(solid longdash shortdash dot dot dot dot dot dot ) ylabel(0.3(0.1).9) xlabel(0(.2)1)
graph export figure6left2.tif, width(2550)
restore

*** Right panel: Less progressive programs
preserve
 lpoly reav strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(treat1) se(treat_se1)
 lpoly housingav strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(control1) se(control_se2)
  lpoly empav strata ,  lpattern(solid) bwidth(0.1) nograph at(strata) gen(treat2) se(treat_se2)
g treated_upper1 = treat1 + (treat_se1)*1.96
g treated_lower1 = treat1 - (treat_se1)*1.96
g untreated_upper1 = control1 + (control_se)*1.96
g untreated_lower1 = control1 - (control_se)*1.96
g treated_upper2 = treat2 + (treat_se2)*1.96
g treated_lower2 = treat2 - (treat_se2)*1.96
sort strata
graph twoway line treat1 control1 treat2 treated_upper1 treated_lower1 untreated_upper1 untreated_lower1 treated_upper2 treated_lower2  strata, legend(order(1 "Inequality" 2 "Housing" 3 "Unemployment" ) rows(1)) ytitle("Share that Approves") xtitle("Strata (low to high)") scheme(s1color)  lcolor(black black black gray gray gray gray gray gray) lpattern(solid longdash shortdash dot dot dot dot dot dot ) ylabel(0.3(0.1).9) xlabel(0(.2)1)
graph export figure6right2.tif, width(2550)
restore

**** Fraction supportive by class 
summarize targetav if strata <.2
summarize healthav if strata <.2
summarize housingav if strata <.2
summarize empav if strata <.2

summarize targetav if strata >.8
summarize healthav if strata >.8
summarize housingav if strata >.8
summarize empav if strata >.8

*** Comparing the slopes across programs
reg health strata female ages educ 
reg employment strata female ages educ

reg targetspend strata female ages educ 
reg housing strata female ages educ

*** Figure 7. Perceptions of Beneficiaries and Taxpayers by Class
*** Left. Bogota Survey
preserve
lpoly lowerclass strata , lpattern(dash) bwidth(0.1) nograph at(strata) gen(control1) se(control_se)
lpoly helpsme strata , lpattern(solid) bwidth(0.1) nograph at(strata) gen(treat1) se(treat_se)
g treated_upper1 = treat1 + (treat_se)*1.96
g treated_lower1 = treat1 - (treat_se)*1.96
g untreated_upper1 = control1 + (control_se)*1.96
g untreated_lower1 = control1 - (control_se)*1.96
sort strata
graph twoway line control1 treat1 untreated_upper1 untreated_lower1 treated_upper1 treated_lower1 strata, legend(order(1 "Poor Get More Benefits" 2 "People Like Me Benefit")) ytitle("Share that Agrees") xtitle("Strata (low to high)") scheme(s1color)  lcolor(black gray black black gray gray ) lpattern(solid longdash dot dot dot dot) ylabel(0.0(0.1).7) xlabel(0(.2)1)
graph export figure7left.tif, width(2550)
restore

*** Fraction that believe that the poor benefits most: 39%
summarize lowerclass, detail

*** Right. LAPOP 2016 Colombia
*** Download from http://datasets.americasbarometer.org/database/

*** Create wealth variable
pca r1 r3 r4 r4a r5 r6 r7 r8 r12 r14 r15 r18 r16 
predict pca2, score
generate consumption = pca2
** deciles
xtile consumpd = consumption, nq(10)
generate deciles = (consumpd-1)/9
** quantiles
xtile consumpq = consumption, nq(5)
generate quantiles= (consumpq-1)/4

*** Fraction that believes that the poor benefit
gen poorbenefit = .
replace poorbenefit = 1 if colsoc15==1
replace poorbenefit= 0 if colsoc15 ==2|colsoc15==3
replace poorbenefit=. if colsoc15==.|colsoc15==4
*** Fraction that believes that the poor pays more in taxes
gen poortax = .
replace poortax = 1 if colsoc14==1
replace poortax= 0 if colsoc14==2|colsoc14==3
replace poortax=. if colsoc14==.|colsoc14==4

*** Graph the different fractions
preserve
lpoly poorbenefit deciles, lpattern(solid) bwidth(0.1) nograph at(deciles) gen(treat1) se(treat_se)
lpoly poortax deciles , lpattern(dash) bwidth(0.1) nograph at(deciles) gen(control1) se(control_se)  
g treated_upper1 = treat1 + (treat_se)*1.96
g treated_lower1 = treat1 - (treat_se)*1.96
g untreated_upper1 = control1 + (control_se)*1.96
g untreated_lower1 = control1 - (control_se)*1.96
sort deciles
graph twoway line treat1 control1 treated_upper1 treated_lower1 untreated_upper1 untreated_lower1 deciles, legend(order(1 "Poor Get More Benefits" 2 "Poor Pay More Taxes" )) ytitle("Share that Agrees") xtitle("Income (low to high)") scheme(s1color)  lcolor(black gray black black gray gray) lpattern(solid longdash dot dot dot dot) ylabel(0.0(0.1).7) xlabel(0(.2)1)
graph export figure7right.tif, width(2550)
restore

*** Fraction that believe that the poor benefits most: 37%
summarize poorbenefit, detail
*** Fraction that believe that the poor pay most in taxes: 41%
summarize poortax, detail

*** Difference in views between the bottom and top of the wealth distribution
summarize poorbenefit if deciles <.3
summarize poorbenefit if decile >.8


*** Figure 8.  Concerns about Increased Social Spending by Class
*** Use qvbogotasurvey.dta

label variable dependence "Benefits Cause Dependence"
label variable buyvotes "Benefits Used to Buy Votes"
label variable reachpoor "Benefits Don't Reach Poor"
label variable middletax "Benefits Require More Taxes on Middle Class" 

generate dependence = 1 if PovertyRisk==1
replace dependence = 0 if PovertyRisk>1 
replace dependence =. if PovertyRisk==.|PovertyRisk==2|PovertyRisk==6

generate buyvotes = 1 if PovertyRisk==3
replace buyvotes = 0 if PovertyRisk!=3 
replace buyvotes =. if PovertyRisk==.|PovertyRisk==2|PovertyRisk==6

generate reachpoor = 1 if PovertyRisk==4
replace reachpoor = 0 if PovertyRisk!=4 
replace reachpoor =. if PovertyRisk==.|PovertyRisk==2|PovertyRisk==6

generate middletax = 1 if PovertyRisk==5
replace middletax  = 0 if PovertyRisk!=5
replace middletax  =. if PovertyRisk==.|PovertyRisk==2|PovertyRisk==6

label define classnames 1 "Lower" 2 "Middle" 3 "Upper" 
label values classgroup classnames 

graph bar reachpoor dependence buyvotes middletax, over(classgroup) ylab(0(.2).6, nogrid) graphregion(fcolor(white)) plotregion(fcolor(white)) bgcolor(white) legend(order(1 "Benefits Don't Reach Poor" 2 "Benefits Cause Dependence" 3 "Benefits Used to Buy Votes" 4 "Middle Class Taxed More"  )) scheme(s2mono)
graph export figure8.tif, width(2550)

summarize reachpoor if classgroup==3
summarize dependence if classgroup==3
summarize buyvotes if classgroup==3


*** Figure 9.  Cross-Region 
*** Use CrossRegion.dta, using income coefficients from ISSP 2006 data and LIS absolute gini reduction

local f0 = "black"
local f1 = "gray"
local f1="light gray"
replace country="US" if country=="USA"
replace country= "S. Korea" if country=="Korea"
replace country="UK" if country=="United Kingdom"
replace country="Czech Rep." if country=="Czech R."
replace country="Sweden" if country=="Sweeden"
replace region = 0 if country=="Japan" |country=="S. Korea"
gen pos=3
replace pos=1 if country=="Czech Rep."|country="Venezuela"
replace pos=12 if country=="Peru"
replace pos=8 if country=="Germany"
replace pos 6 if country=="Uruguay"
replace pos = 5 if country=="Colombia"
replace pos=2 if country=="Bolivia"
replace pos=9 if country=="Germany"
replace pos=4 if country=="Slovenia"
replace pos=12 if country=="Peru"
twoway (scatter coef lisabsolute if region==3, mcolor(black) mlabcolor(black) msymbol(smcircle) msize(large) mlabel(country) mlabvposition(pos))(scatter coef lisabsolute if region==0, mcolor(gray) mlabcolor(gray) msymbol(smcircle) msize(large) mlabel(country) mlabvposition(pos)) (lfit coef lisabsolute, lcolor(gray) ytitle("Income Coefficient") xtitle("Absolute Redistribution") xlab(0(10)50) ylab(-.25(.05).05, nogrid) graphregion(fcolor(white)) plotregion(fcolor(white)) bgcolor(white) legend( order(1 "Latin America" 2 "OECD") rows(1) pos(5)))
graph export figure9.tif, width(2550)

*** Supplementary Materials 
*** Section A. Additional Benefit Receipt Models
*** Appendix Table 1, OLS and Logistic Regression Coefficients

eststo clear
eststo, title("Model 1"): quietly xi: reg redistribution benefits deciles education female size age nonwhite i.country i.year, robust
eststo, title("Model 2"): quietly xi: reg redistribution benefits deciles education female size age nonwhite right religion unemployed client crimeproblem bbribe i.country i.year, robust
eststo, title("Model 3"): quietly xi: reg redistribution benefits deciles education female size age nonwhite healthresponse i.country, robust
eststo, title("Model 4"): quietly xi: logit demand benefits deciles education female size age nonwhite i.country i.year, robust
eststo, title("Model 5"): quietly xi: logit demand benefits deciles education female size age nonwhite right religion unemployed client crimeproblem bbribe i.country i.year, robust
eststo, title("Model 6"): quietly xi: logit demand benefits deciles education female size age nonwhite healthresponse i.country, robust
estout, style(tex) varlabels(_cons \_cons)
esttab using AppendixTable1.tex, keep(benefits deciles education female size age nonwhite healthresponse right religion unemployed client crimeproblem bbribe) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Table A1\label{olslogit}")  

*** Appendix Table 2, Disaggregated Benefits and Self-Reported Income Specifications, OLS
eststo clear
eststo, title("Model 1"): quietly xi: reg redistribution pension deciles education female size age nonwhite i.country, robust
eststo, title("Model 2"): quietly xi: reg redistribution health deciles education female size age nonwhite i.country, robust
eststo, title("Model 3"): quietly xi: reg redistribution subsidy deciles education female size age nonwhite i.country i.year, robust
eststo, title("Model 4"): quietly xi: reg redistribution cct deciles education female size age nonwhite i.country i.year, robust
eststo, title("Model 5"): quietly xi: reg redistribution lincome benefits education female size age nonwhite i.country i.year, robust
eststo, title("Model 6"): quietly xi: reg redistribution lincome benefits education female size age nonwhite right religion unemployed client crimeproblem bbribe i.country i.year, robust
eststo, title("Model 7"): quietly xi: reg redistribution lincome benefits education female size age nonwhite healthresponse i.country, robust
estout, style(tex) varlabels(_cons \_cons)
esttab using AppendixTable2.tex, keep(benefits lincome deciles education female size age nonwhite healthresponse right religion unemployed client crimeproblem bbribe pension health subsidy cct) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Table A2\label{selfincome}")  

*** Appendix Table 3. Summary Statistics, LAPOP Individual-Level Variables 
sutex redistribution demand benefits pension health subsidy cct deciles lincome education female size age nonwhite unemployed client crimeproblem bbribe healthresponse, lab nobs key(descstat) replace file(descstat.tex) title("Table A3\label{sumindividual}") minmax

*** Section B. Hierarchical Models

*** Appendix Table 4.  Predicting Income Coefficients with Benefit Redistribution
preserve
collapse totalslope ginisasi gini_sa gini_si gini_market5 socialexp gni_pc_1000 effectiveness_raw ef inc lrule se_slope, by(country year)
eststo clear
eststo, title("Model 1"): quietly reg totalslope ginisasi gini_market5 socialexp gni_pc_1000 i.year [aweight=1/se_slope]
eststo, title("Model 2"): quietly reg totalslope ginisasi gni_pc_1000 gini_market5 socialexp effectiveness_raw i.year [aweight=1/se_slope]
eststo, title("Model 3"): quietly reg totalslope ginisasi gni_pc_1000 gini_market5 socialexp ef inc lrule i.year [aweight=1/se_slope]
eststo, title("Model 4"): quietly xi: reg totalslope gini_sa gini_market5 socialexp gni_pc_1000 i.year [aweight=1/se_slope]
eststo, title("Model 5"): quietly xi: reg totalslope gini_sa gni_pc_1000 gini_market5 socialexp effectiveness_raw i.year [aweight=1/se_slope]
eststo, title("Model 6"): quietly xi: reg totalslope gini_sa gni_pc_1000 gini_market5 socialexp ef inc lrule i.year [aweight=1/se_slope]
eststo, title("Model 7"): quietly xi: reg totalslope gini_si gni_pc_1000 gini_market5 socialexp i.year [aweight=1/se_slope]
eststo, title("Model 8"): quietly xi: reg totalslope gini_si gni_pc_1000 gini_market5 socialexp effectiveness i.year [aweight=1/se_slope]
eststo, title("Model 9"): quietly xi:  reg totalslope gini_si gni_pc_1000 gini_market5 socialexp ef inc lrule i.year [aweight=1/se_slope]
estout, style(tex) varlabels(_cons \_cons) 
esttab using AppendixTable4.tex, keep(ginisasi gini_sa gini_si gini_market5 socialexp gni_pc_1000 effectiveness_raw ef inc lrule) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Table 1\label{higherorder}")
restore

*** Appendix Table 5. Cross-Level Models for Coverage and Progressivity 

*** Generate interactions with income 
g ginisasi = gini_sa + gini_si
g cover_dec = covaverage*deciles
g absred_dec = abs_red*deciles
g ginisasi_dec = ginisasi*deciles
g social_dec = socialexp*deciles

eststo clear
eststo, title("Model 1"): quietly mixed redistribution deciles age size female education i.year || country: deciles
eststo, title("Model 2"): quietly mixed redistribution deciles age size female education covaverage cover_dec i.year || country: deciles 
eststo, title("Model 3"): quietly mixed redistribution deciles age size female education covaverage cover_dec if year==2010 || country: deciles 
eststo, title("Model 4"): quietly mixed redistribution deciles age size female education socialexp social_dec if year==2010 || country: deciles 
eststo, title("Model 5"): quietly mixed redistribution deciles age size female education abs_red absred_dec i.year || country: deciles
eststo, title("Model 6"): quietly mixed redistribution deciles age size female education ginisasi ginisasi_dec i.year || country: deciles
eststo, title("Model 7"): quietly mixed redistribution deciles age size female education covaverage cover_dec gini_market5 ef inc effectiveness_raw gni_pc_1000 socialexp lrule if year==2010 || country: deciles 
eststo, title("Model 8"): quietly mixed redistribution deciles age size female education socialexp social_dec gini_market5 ef inc effectiveness_raw gni_pc_1000 lrule if year==2010 || country: deciles 
eststo, title("Model 9"): quietly mixed redistribution deciles age size female education abs_red absred_dec gini_market5 ef inc effectiveness_raw gni_pc_1000 socialexp lrule i.year || country: decile
eststo, title("Model 10"): quietly mixed redistribution deciles age size female education ginisasi ginisasi_dec gini_market5 ef inc effectiveness_raw gni_pc_1000 socialexp lrule i.year || country: deciles
estout, style(tex) varlabels(_cons \_cons) 
esttab using AppendixTable5.tex, keep(covaverage abs_red ginisasi cover_dec socialexp social_dec absred_dec ginisasi_dec deciles education female size age gini_market5 socialexp gni_pc_1000 ef effectiveness_raw lrule) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Redistributive Preferences, Hierarchical Models\label{income}")  
esttab using appvariance5.tex, se wide nostar transform(ln*: exp(2*@) 2*exp(2*@)) eqlabels("" "var(Income)" "var(Constant)" "var(Residual)", none) varlabels(,elist(weight:_cons "{break}{hline @width}")) cells(b(star fmt(3)) se(par fmt(3)))


***  Appendix Table 6. Cross-Level Models for Alternative Explanations 

*** Using cross-level models to think about both the level effect and relationship
*** with income polarization (the interaction term)

gen deccapacity=effectiveness_raw*deciles
gen deccorrupt = corruption_raw*deciles
gen decef=ef*deciles
gen decleft= lrule*deciles 
gen densityint = densityu*deciles
gen bgiint= bgi*deciles
gen progint = programmatic*deciles
gen dectax = inc*deciles
gen nontaxint = rev_residual*deciles

eststo clear
eststo, title("Model 1"): quietly mixed redistribution deciles age size female education inc dectax i.year || country: deciles
eststo, title("Model 2"): quietly mixed redistribution deciles age size female education rev_residual nontaxint i.year || country: deciles
eststo, title("Model 3"): quietly mixed redistribution deciles age size female education effectiveness_raw deccapacity i.year || country: deciles
eststo, title("Model 4"): quietly mixed redistribution deciles age size female education corruption_raw deccorrupt i.year || country: deciles
eststo, title("Model 5"): quietly mixed redistribution deciles age size female education ef decef  || country: deciles 
eststo, title("Model 6"): quietly mixed redistribution deciles age size female education bgi bgiint i.year || country: deciles
eststo, title("Model 7"): quietly mixed redistribution deciles age size female education lrule decleft  || country: deciles
eststo, title("Model 8"): quietly mixed redistribution deciles age size female education densityu densityint i.year || country: deciles
eststo, title("Model 9"): quietly mixed redistribution deciles age size female education programmatic progint  || country: deciles
estout, style(tex) varlabels(_cons \_cons) 
esttab using AppendixTable6.tex, keep(effectiveness_raw deccapacity ef decef bgi bgiint inc dectax rev_residual nontaxint lrule decleft densityu densityint densityu densityint programmatic progint deciles education female size age) 

stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Redistributive Preferences, Hierarchical Models\label{income}")  
esttab using tablevariance6.tex, se wide nostar transform(ln*: exp(2*@) 2*exp(2*@)) eqlabels("" "var(Income)" "var(Constant)" "var(Residual)", none) varlabels(,elist(weight:_cons "{break}{hline @width}")) cells(b(star fmt(3)) se(par fmt(3)))
 
*** Appendix Table 7. Robustness of Progressivity to Tax and State Capacity Measures 

eststo clear
eststo, title("Model 1"): quietly mixed redistribution deciles age size female education covaverage cover_dec inc dectax if year==2010 || country: deciles 
eststo, title("Model 2"): quietly mixed redistribution deciles age size female education socialexp social_dec inc dectax if year==2010 || country: deciles 
eststo, title("Model 3"): quietly mixed redistribution deciles age size female education abs_red absred_dec inc dectax i.year || country: deciles 
eststo, title("Model 4"): quietly mixed redistribution deciles age size female education ginisasi ginisasi_dec inc dectax i.year || country: deciles 
eststo, title("Model 5"): quietly mixed redistribution deciles age size female education covaverage cover_dec effectiveness_raw deccapacity if year==2010 || country: deciles
eststo, title("Model 6"): quietly mixed redistribution deciles age size female education socialexp social_dec effectiveness_raw deccapacity if year==2010 || country: deciles 
eststo, title("Model 7"): quietly mixed redistribution deciles age size female education abs_red absred_dec effectiveness_raw deccapacity i.year || country: deciles 
eststo, title("Model 8"): quietly mixed redistribution deciles age size female education ginisasi ginisasi_dec effectiveness_raw deccapacity i.year || country: deciles 
esttab using AppendixTable7.tex, keep(covaverage abs_red ginisasi cover_dec absred_dec ginisasi_dec effectiveness_raw deccapacity inc dectax deciles education female size age) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Redistributive Preferences, Hierarchical Models\label{robustness}") 
esttab using tablevariance7.tex, se wide transform(ln*: exp(2*@) 2*exp(2*@)) eqlabels("" "var(Income)" "var(Constant)" "var(Residual)", none) varlabels(,elist(weight:_cons "{break}{hline @width}")) replace cells(b(star fmt(3)) se(par fmt(3)))

*** Appendix Table 8.  Summary Statistics for national-level variables 

preserve 
collapse covaverage abs_red ginisasi gini_sa gini_si socialexp gini_market5 gni_pc_1000 ef bgi inc rev_residual effectiveness_raw corruption_raw lrule densityu programmatic, by(country year)
sutex covaverage abs_red ginisasi gini_sa gini_si socialexp gini_market5 gni_pc_1000 ef bgi inc rev_residual effectiveness_raw corruption_raw lrule densityu programmatic, lab nobs key(horder) replace file(higherordersum.tex) title("Summary Statistics, National Varialbes") minmax 
restore 

*** Appendix Table 10. Benefit Expectations on Bogota Survey
*** Benefits: "1" if the person gets cct, subsidized health, or pensions
generate benefits = 0
replace benefits = 1 if cctr==1|healthsub==1|peninc==1
replace benefits = . if cctr==.&healthsub==.|peninc==.

eststo clear
eststo, title("Model 1"): quietly: reg helpsme benefits strata female ages educ 
eststo, title("Model 2"): quietly: reg helpsme healthsub peninc cctr strata female ages educ 
eststo, title("Model 3"): quietly: reg targetspend helpsme benefits strata female ages educ 
eststo, title("Model 4"): quietly: reg health helpsme benefits strata female ages educ 
eststo, title("Model 5"): quietly: reg employment helpsme benefits strata female ages educ 
eststo, title("Model 6"): quietly: reg housing helpsme benefits strata female ages educ 
eststo, title("Model 7"): quietly: reg redistribution helpsme benefits strata female ages educ 
eststo, title("Model 8"): quietly: reg tax helpsme benefits strata female ages educ 
esttab using AppendixTable9.tex, keep(benefits healthsub peninc cctr helpsme strata female ages educ) stats(r2 N) replace b (3) se (3) ar2 star(* 0.05 ) label title("Table A1\label{benefits}")  
 
*** Appendix Table 11. Bogota 2014 Survey Demographics

sutex targetspend health employment housing redistribution tax helpsme benefits healthsub peninc cctr strata female ages educ , lab nobs key(horder) replace file(bogotasummary.tex) title("Summary Statistics, Bogota Survey") minmax 

